/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ifpb.banco.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Vanderlan
 */
@Entity
@Table(catalog = "", schema = "VANDERLAN")
@SequenceGenerator(name = "S_HOSPEDAGEM_PK", sequenceName = "S_HOSPEDAGEM_PK")
public class Hospedagem extends Identificavel {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "COD_HOSPEDAGEM", nullable = false, precision = 0, scale = -127)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "S_HOSPEDAGEM_PK")
    protected Long id;
    @Basic(optional = false)
    @Column(name = "DATA_ENTRADA", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataEntrada;
    @Column(name = "DATA_SAIDA")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataSaida;
    @Column(precision = 10, scale = 2)
    private BigDecimal valor;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codHospedagem")
    private Collection<Hospede> hospedeCollection;
    @JoinColumn(name = "COD_CLIENTE", referencedColumnName = "COD_CLIENTE", nullable = false)
    @ManyToOne(optional = false)
    private Cliente codCliente;
    @JoinColumn(name = "COD_APARTAMENTO", referencedColumnName = "COD_APARTAMENTO", nullable = false)
    @ManyToOne(optional = false)
    private Apartamento codApartamento;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codHospedagem")
    private Collection<ServicoSolicitado> servicoSolicitadoCollection;

    public Hospedagem() {
    }

    public Hospedagem(Long codHospedagem) {
        this.id = codHospedagem;
    }

    public Hospedagem(Long codHospedagem, Date dataEntrada) {
        this.id = codHospedagem;
        this.dataEntrada = dataEntrada;
    }

    public Long getCodHospedagem() {
        return id;
    }

    public void setCodHospedagem(Long codHospedagem) {
        this.id = codHospedagem;
    }

    public Date getDataEntrada() {
        return dataEntrada;
    }

    public void setDataEntrada(Date dataEntrada) {
        this.dataEntrada = dataEntrada;
    }

    public Date getDataSaida() {
        return dataSaida;
    }

    public void setDataSaida(Date dataSaida) {
        this.dataSaida = dataSaida;
    }

    public BigDecimal getValor() {
        return valor;
    }

    public void setValor(BigDecimal valor) {
        this.valor = valor;
    }

    public Collection<Hospede> getHospedeCollection() {
        return hospedeCollection;
    }

    public void setHospedeCollection(Collection<Hospede> hospedeCollection) {
        this.hospedeCollection = hospedeCollection;
    }

    public Cliente getCodCliente() {
        return codCliente;
    }

    public void setCodCliente(Cliente codCliente) {
        this.codCliente = codCliente;
    }

    public Apartamento getCodApartamento() {
        return codApartamento;
    }

    public void setCodApartamento(Apartamento codApartamento) {
        this.codApartamento = codApartamento;
    }

    public Collection<ServicoSolicitado> getServicoSolicitadoCollection() {
        return servicoSolicitadoCollection;
    }

    public void setServicoSolicitadoCollection(Collection<ServicoSolicitado> servicoSolicitadoCollection) {
        this.servicoSolicitadoCollection = servicoSolicitadoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Hospedagem)) {
            return false;
        }
        Hospedagem other = (Hospedagem) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ifpb.banco.principal.entity.Hospedagem[ codHospedagem=" + id + " ]";
    }
    
}
